const express = require('express');
const router = express.Router();
loginService = require('../service/login');

/**
 * @apiGroup 认证 /
 * @api {post} /login 登录 /login [张会壮]
 * @apiDescription 张会壮
 * @apiBody {string} username 用户名
 * @apiBody {string} password 密码
 * @apiSampleRequest /login
 * @apiVersion 1.0.0
 */
router.post('/login', (req, res, next) => {
    loginService.login(req, res, next).catch(e => res.send(e))
});

/**
 * @apiGroup 认证 /
 * @api {post} /logout 退出 /logout [张会壮]
 * @apiDescription 无
 * @apiSampleRequest /logout
 * @apiVersion 1.0.0
 */
router.post('/logout', (req, res, next) => {
    loginService.logout(req, res, next).catch(e => res.send(e))
});

module.exports = router;
